package com.chain.qs.modules.biz.dp.handler.device;

import com.chain.qs.modules.biz.dp.handler.AbstractDPHandler;
import com.chain.qs.modules.biz.entity.EquipmentItemRecordSensor;
import com.chain.qs.modules.biz.service.EquipmentItemRecordSensorService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 温湿度传感器
 */
@Component("QHHumTemDev")
public class QHHumTemDev extends AbstractDPHandler {
    @Resource
    private EquipmentItemRecordSensorService equipmentItemRecordSensorService;

    public void saveData(Map<String, Object> params) {
        EquipmentItemRecordSensor entity = new EquipmentItemRecordSensor();
        entity.setOfficeCode(officeCode);
        entity.setSgroupId(sgroupId);
        entity.setGitemId(deviceId);
        entity.setHumidity(params.get("hum") == null ? "" : params.get("hum").toString());
        entity.setTemperature(params.get("temp") == null ? "" : params.get("temp").toString());
        entity.setTimeStamp(new Timestamp(System.currentTimeMillis()));
        equipmentItemRecordSensorService.save(entity);
    }
}
